<template>
  <div id="category">
    <!-- 面包屑导航区域 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item><a href="/home">首页</a></el-breadcrumb-item>
      <el-breadcrumb-item>商品管理</el-breadcrumb-item>
      <el-breadcrumb-item>商品分类</el-breadcrumb-item>
    </el-breadcrumb>

    <!-- 卡片视图区域 -->
    <el-card>
      <el-row>
        <el-col>
          <el-button type="primary">添加分类</el-button>
        </el-col>
      </el-row>

      <!-- 表格区域 -->
      <el-row>
        <tree-table :data="categoryList">
          <tree-table-column type='seq' title="Seq"></tree-table-column>
          <tree-table-column field='cate_name' title="商品名称"></tree-table-column>
        </tree-table>
      </el-row>

      <!-- 分页区域 -->
    </el-card>
  </div>
</template>

<script>
import { ref } from 'vue'
export default {
  name: 'category',
  data() {
    return {
      categoryList: ref([]),
      columns: [
        {
          label: '分类名称',
          prop: 'cate_name',
        },
      ],
    }
  },
  created() {
    this.getCategoryList()
  },
  methods: {
    async getCategoryList() {
      const { data: res } = await this.$http.get('categories')
      if (res.meta.status !== 200) {
        return this.$message.error('初始化商品分类数据失败！')
      }
      this.categoryList = ref(res.data)
    },
  },
}
</script>

<style lang="less" scoped>
</style>
